// pages/create_sick/create_sick.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name:'',
    patient_id_card:'',
    id_card:'',
    sick_img:'',
    phone:''
  },

  name(res){
    this.setData({
      name:res.detail.value
    })
  },

  patient_id_card(res){
    this.setData({
      patient_id_card:res.detail.value
    })
  },

  id_card(res){
    this.setData({
      id_card:res.detail.value
    })
  },

  phone(res){
    this.setData({
      phone:res.detail.value
    })
  },

  onChangeTap(res){
    var that=this
    var img=res.detail.all
      wx.uploadFile({
        filePath: img[0],
        name: 'sick_img',
        url: 'http://www.healthcare.com/api/wzm/create_sick_img',
        success:(res)=>{
          that.setData({sick_img:res.data})
          // console.log(that.data.sick_img)
        }
      })
  },

  submit(res){
    var name = this.data.name
    var patient_id_card = this.data.patient_id_card
    var id_card = this.data.id_card
    var sick_img = this.data.sick_img
    var phone = this.data.phone
    wx.request({
      url: 'http://www.healthcare.com/api/wzm/create_sick',
      method:"POST",
      data:{
        name,patient_id_card,id_card,sick_img,phone
      },
      success:(res)=>{
        wx.redirectTo({
          url: '/pages/be_in_hospital/be_in_hospital',
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})